package com.googlecode.monitoring.db.model;

import com.googlecode.monitoring.model.EventTime;
import com.googlecode.monitoring.model.ItemToCheck;
import com.googlecode.monitoring.model.Person;
import com.googlecode.monitoring.model.StateName;

import java.io.Serializable;
import java.util.Set;

/**
 * Author: Sergiy Doroshenko
 * Date: May 14, 2010
 * Time: 4:25:00 PM
 */
public class DbItemToCheck extends ItemToCheck implements Serializable {
	private TableOfData table;
	private MaxAgeOfData maxAgeOfData;
    private DataSourceItem dataSourceItem;

	public DbItemToCheck() {
		super();
	}

	public DbItemToCheck(String id,String name, DataSourceItem dataSourceItem, TableOfData table, MaxAgeOfData maxAgeOfData, EventTime eventTime, Set<Person> responsiblePerson, String descr, StateName currentStateName) {
        this.setDataSourceItem(dataSourceItem);
        this.setId(id);
        this.setName(name);
		this.table = table;
		this.maxAgeOfData = maxAgeOfData;
		this.eventTime = eventTime;
		this.responsiblePersons = responsiblePerson;
		this.descr = descr;
		this.currentStateName = currentStateName;
	}

    public DataSourceItem getDataSourceItem() {
        return dataSourceItem;
    }

    public void setDataSourceItem(DataSourceItem dataSourceItem) {
        this.dataSourceItem = dataSourceItem;
    }

    public TableOfData getTable() {
		return table;
	}

	public void setTable(TableOfData table) {
		this.table = table;
	}

	public MaxAgeOfData getMaxAgeOfData() {
		return maxAgeOfData;
	}

	public void setMaxAgeOfData(MaxAgeOfData maxAgeOfData) {
		this.maxAgeOfData = maxAgeOfData;
	}

	@Override
	public String toString() {
		return "DbItemToCheck{" +
			"id=" + id +
			", table=" + table +
			", maxAgeOfData=" + maxAgeOfData +
			", eventTime=" + eventTime +
			", responsiblePersons=" + responsiblePersons +
			", descr='" + descr + '\'' +
			", currentState=" + currentStateName +
            ", datasource=" + dataSourceItem +
            ", lastCheckTime=" + lastCheckTime +
			'}';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}

		DbItemToCheck that = (DbItemToCheck) o;

		if (id != null ? !id.equals(that.id) : that.id != null) {
			return false;
		}
		return true;
	}

	@Override
	public int hashCode() {
		int result = id.hashCode();
		return result;
	}
}
